<?
	require_once 'dir.php';
	// Fmgr0v0r01__uniqueDir is the base class for all unique directories, including _rootdir. It is not instanitiated.
	// rdk & mod are the important variables here

	class Fmgr0v0r01__uniquedir extends Fmgr0v0r01_dir{

		protected $rdk;
			
		function read_only_keys(){
			static $a;
			if($a) return $a;
			$a = array_merge(parent::read_only_keys(), array(
				'fmrp','class','mod'
			));
			return $a;	
		}
		
		function critical_defaults(){
			return array_merge(parent::critical_defaults(), array(
				'mod' => $this->mod,
				'fmrp' => $this->rdk.':'.$this->href()
			));	
		}
			
		protected $udnames = array();
		protected $ufnames = array();
		
		function name(){
			return $this->class;	
		}
		
		function href(){
			return '/'.strtolower($this->class);	
		}
		
		function init_uniq(){
			if($this->udnames) foreach($this->udnames as $n) $this->getObj($n);
			if($this->ufnames) foreach($this->ufnames as $n) $this->getObj($n);
		}
		
		protected function read_permissions(){
			parent::read_permissions();
			if(!$this->exists()) mkdir($this->realpath(), 0755) or httpE(500, $this->fmrp." has no associated directory"); 
		}
		
		// getObj allows us to have unique classes as firstchild of root directory.
		// Desk and Shar use these, while Docs may not (unless you write one of your own :)
		function getObj($cname){
			if(!$this->allow_read) return false;
			return ($o = $this->child(strtolower($cname))) ? $o : $this->initObj($cname);
		}
		
		protected function initObj($cname){
			$o = false;
			if(in_array($cname, $this->udnames)) $o = $this->mkdir(strtolower($cname));
			elseif(in_array($cname, $this->ufnames)) $o = $this->mkfil(strtolower($cname));
			if($o && (smuoi_is_dir($o))) $o->init_uniq();
			return $o;
		}

		// for sanity & simplicity...overrule the inherited functions
		protected function set_mod(){
			return false;
		}
		
		protected function set_par(){
			return false;
		}
		
		protected function set_basename(){
			return false;
		}
		
		function duplicate(){
			return false;	
		}
		
		function copy_to(){
			return false;	
		}

		function is_trashable(){
			return false;
		}

		function is_destroyable(){
			return false;
		}
		
		function destroy(){
			return false;
		}
	}

?>